package com.qfedu.buy.server.listener;

import com.qfedu.buy.common.config.RabbitMQConstantConfig;
import com.qfedu.buy.common.dto.CartNumDto;
import com.qfedu.buy.server.dao.CartItemDao;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @program: NeighborBuy
 * @description:
 * @author: Feri(邢朋辉)
 * @create: 2021-02-02 11:06
 */
@Component
@RabbitListener(queues = RabbitMQConstantConfig.QUEUE_CART_NUM)
public class CartNumListener {
    @Autowired
    private CartItemDao dao;
    @RabbitHandler
    public void handler(CartNumDto dto){
        if(dto!=null && dto.getId()>0){
            dao.update(dto.getId(),dto.getNum());
        }
    }
}
